package com.vf.admin.client.service.impl;

import com.vf.admin.client.dao.AppFollowDao;
import com.vf.admin.client.service.AppFollowService;
import com.vf.admin.common.splitpage.SplitPageBean;
import com.vf.admin.miaodong.entity.AppFollow;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 关注
 */
@Service
public class AppFollowServiceImpl implements AppFollowService {

    @Autowired
    AppFollowDao appFollowDao;

    @Override
    public List<AppFollow> list(Map<String, Object> paraMap, SplitPageBean splitPage) {
        return appFollowDao.list(paraMap, splitPage);
    }

    @Override
    public AppFollow get(Integer id) {
        return appFollowDao.get(id);
    }

    @Override
    public AppFollow getFollew(Integer guanUserId,Integer beiUserId) {
        return appFollowDao.getFollew(guanUserId,beiUserId);
    }

    @Override
    public void save(AppFollow haoYou) {
        appFollowDao.save(haoYou);
    }

    @Override
    public void del(Integer id) {
        appFollowDao.del(id);
    }

    @Override
    public List<AppFollow> findByList(Map<String, Object> paraMap, SplitPageBean splitPage) {
        return appFollowDao.findByList(paraMap, splitPage);
    }

    @Override
    public List<AppFollow> findByListAll(Map<String, Object> paraMap) {
        return appFollowDao.findByListAll(paraMap);
    }

    @Override
    public List<AppFollow> getPiliang(Integer userid, String arr) {
        return appFollowDao.getPiliang(userid, arr);
    }

    /**
     * 根据用户ID 查询关注的集合
     * @param id
     * @return
     */
    @Override
    public List<AppFollow> selectALL(Integer id) {
        return appFollowDao.selectALL(id);
    }


    /**
     * 获取一天内的新粉丝数
     *
     * @return
     */
    @Override
    public List<AppFollow> getNewFansByDay() {
        return appFollowDao.getNewFansByDay();
    }

    /**
     * 获取7天内的粉丝数
     *
     * @return
     */
    @Override
    public List<AppFollow> getNewFansBySevenDay() {
        return appFollowDao.getNewFansBySevenDay();
    }

    /**
     * 查询用户的粉丝总数
     * @param userIds
     * @return
     */
    @Override
    public Integer queryFollowSum(String userIds) {
        List<AppFollow> appFollows = appFollowDao.queryFollowSum(userIds);
        return appFollows.size();
    }

    @Override
    public Integer queryFollowSum(Integer userId) {
        List<AppFollow> appFollows = appFollowDao.queryFollowSum(userId);
        return appFollows.size();
    }

    /**
     * 查看两人是否互相关注
     * @param userId
     * @param userId1
     * @return
     */
    @Override
    public boolean isEachFollow(Integer userId, Integer userId1) {
        AppFollow follew = appFollowDao.getFollew(userId, userId1);
        AppFollow follew1 = appFollowDao.getFollew(userId1, userId);

        return follew != null && follew1 != null;
    }


}
